package com.wd.task;

import java.util.ArrayList;
import java.util.List;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import us.codecraft.webmagic.pipeline.Pipeline;

import com.wd.core.spring.support.SpringUtils;
import com.wd.jdbc.LobJobService;
import com.wd.live.platform.AbstractProcessor;
import com.wd.live.platform.DouyuRepoPageProcessor;
import com.wd.live.platform.HuyaRepoPageProcessor;
import com.wd.live.platform.LongzhuRepoPageProcessor;
import com.wd.live.platform.MyJdbcPipeline;
import com.wd.live.platform.PandaPageProcessor;
import com.wd.live.platform.QuanminRepoPageProcessor;
import com.wd.live.platform.ZhanqiRepoPageProcessor;
import com.wd.model.LogJob;

@Component
public class LiveStarTask {

	
	@Scheduled(cron = "0 30 12  * * *")
	@Scheduled(cron = "0 30 18  * * *")
	@Scheduled(cron = "0 30 21  * * *")
	public void execute() {
		Pipeline pipeline = new MyJdbcPipeline();
		List<AbstractProcessor> list = new ArrayList<AbstractProcessor>();
		list.add(new DouyuRepoPageProcessor(pipeline));
		list.add(new HuyaRepoPageProcessor(pipeline));
		list.add(new LongzhuRepoPageProcessor(pipeline));
		list.add(new PandaPageProcessor(pipeline));
		list.add(new QuanminRepoPageProcessor(pipeline));
		list.add(new ZhanqiRepoPageProcessor(pipeline));
		
		for(AbstractProcessor a :list){
			a.execute();
		}
		LogJob logJob = new LogJob();
		logJob.setType(LiveStarTask.class.getSimpleName());
		logJob.setRemark("OK");
		
		LobJobService ds = (LobJobService) SpringUtils.getBean("lobJobService");
		ds.insertData(logJob);
		
	}
}